The toast view modifier displays a temporary notification message (toast) over the current view.
It is typically used to show short feedback messages such as “Saved successfully,” “Action completed,” or “Network error.”
You can show a simple text message or provide a fully custom view as the toast’s content. You can also control its duration, position, background color, text color, corner radius, and shadow style.
isPresented: boolean and onChanged(isPresented: boolean): voidDescription:
Uses the isPresented and onChanged properties to control the visibility and behavior of the toast.
Example:
isPresented: Observable<boolean>Description:
Uses the isPresented observable to control the visibility and behavior of the toast.
Example:
duration?: number | nullDescription:
Specifies how long (in seconds) the toast should remain visible.
Defaults to 2 seconds.
Example:
position?: "top" | "bottom" | "center"Description: Controls where the toast appears on the screen.
Available values:
"top" – Displays the toast at the top."bottom" – Displays the toast at the bottom (default)."center" – Displays the toast in the center.Example:
backgroundColor?: Color | nullDescription: Sets the background color of the toast.
Example:
textColor?: Color | nullDescription: Sets the text color of the toast message.
Example:
cornerRadius?: number | nullDescription:
Sets the corner radius of the toast.
Defaults to 16.
Example:
shadowRadius?: number | nullDescription:
Sets the blur radius of the toast’s shadow.
Defaults to 4.
Example:
Example:
When the button is pressed, a green toast with the message “Data saved successfully” appears at the bottom for 2 seconds.
Description:
Instead of plain text, you can provide a custom VirtualNode (view) as the toast content.
This allows you to include icons, multiple text lines, or other view layouts.
Example:
This example shows a custom toast with an icon and message inside a black rounded background.
Keep state synchronized
Always ensure isPresented and onChanged stay in sync so the toast can be properly dismissed.
Use for lightweight notifications Toasts should only display short, transient messages and should not include complex interactions.
Avoid multiple simultaneous toasts Displaying more than one toast at the same time may confuse users.
Combine with user actions
Pair the toast with Button, Form, or other components to provide quick feedback after an action.